<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        window.onload=function(){
            document.getElementsByTagName("input")[3].onclick=function(){
                var y=Number(document.getElementsByTagName("input")[0].value);
                var m=Number(document.getElementsByTagName("input")[1].value);
                if((y%4===0)&&(y%100!=0)){
                   switch(m){
                       case 1:
                       case 3:
                       case 5:
                       case 7:
                       case 8:
                       case 10:
                       case 12:document.getElementsByTagName("input")[2].value=31;break;
                       case 4:
                       case 6:
                       case 9:
                       case 11:document.getElementsByTagName("input")[2].value=30;break;
                       case 2:document.getElementsByTagName("input")[2].value=29;break;
                       default:document.getElementsByTagName("input")[2].value="输入错误";
                   }
                }else{
                    switch(m){
                        case 1:
                       case 3:
                       case 5:
                       case 7:
                       case 8:
                       case 10:
                       case 12:document.getElementsByTagName("input")[2].value=31;break;
                       case 4:
                       case 6:
                       case 9:
                       case 11:document.getElementsByTagName("input")[2].value=30;break;
                       case 2:document.getElementsByTagName("input")[2].value=28;break;
                       default:document.getElementsByTagName("input")[2].value="输入错误";
                   }
                }
            }
            document.getElementsByTagName("input")[4].onclick=function(){
                document.getElementsByTagName("input")[0].value="";
                document.getElementsByTagName("input")[1].value="";
                document.getElementsByTagName("input")[2].value="";
            }
        }
    </script>
</head>
<body>
    <h1>请输入年和月求当月天数</h1>
    <input type="text" name="" id="" placeholder="请输入年">年
    <input type="text" name="" id="" placeholder="请输入月">月有
    <input type="text" name="" id="" placeholder="点就获得结果">天
    <input type="button" value="确定">
    <input type="button" value="重置">
</body>
</html>